package com.atqinke.designpattern.behavioraltype.iterator;

import java.util.List;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.designpattern.behavioraltype.iterator
 * @Author: NieHk
 * @CreateTime: 2022-08-29  15:41
 * @Description:
 * @Version: 1.0
 */
public class ObjectIteratorImpl implements ObjectIterator{

    private List list;
    private int position = 0;

    public ObjectIteratorImpl(List list) {
        this.list = list;
    }


    @Override
    public boolean hasNext() {
        return position < list.size();
    }

    @Override
    public Object next() {
        Object o = list.get(position);
        position ++;
        return o;
    }
}
